package com.foreknow.springboot.threaddemo;

public class SleepDemo {
    public static void main(String[] args) {

        new Thread("线程1"){
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    //线程休眠  500是指500毫秒
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(getName()+"执行了！！！");
                }
            }
        }.start();

        new Thread("线程2"){
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    //线程休眠  500是指休眠500毫秒
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(getName()+"执行了！！！");
                }
            }
        }.start();

    }
}
